<template>
  <Validator ref="refStep1" @submit="changeCurStep(2)"></Validator>
  <SealSelector ref="refStep2" @submit="doSealAdd"></SealSelector>
</template>
<script setup>
import { reactive, ref, inject } from "vue";
import Validator from "./_validator.vue";
import SealSelector from "./_sealSelector.vue";
import { seal, ss } from "@/utils";

const provideHome = inject("provideHome");
const refStep1 = ref();
const refStep2 = ref();
const state = reactive({
  style: {},
  formData: {},
});

const changeCurStep = curStep => {
  refStep1.value.close();
  refStep2.value.close();
  if (curStep == 1) {
    refStep1.value.show();
  } else if (curStep == 2) {
    refStep2.value.show();
  }
  setTimeout(() => {
    provideHome.methods.setSealCurrentOperateName("btnSealAddNormal");
  }, 30);
};

const doSealAdd = async params => {
  let { sealInfo, posInfo } = params;
  await seal.doSealAdd({
    fileId: ss.get("fileId"),
    signatureInfo: {
      signatureType: "custom",
      page: posInfo.page,
      x: posInfo.left,
      y: posInfo.top,
    },
    sealSn: sealInfo.sealSn,
    positionType: 1,
    signContinued: "00", //单页签章
    sealType: sealInfo.sealType,
  });
};

defineExpose({
  show() {
    changeCurStep(1);

    // kings mock
    // changeCurStep(2);
  },
});
</script>
<style lang="scss"></style>
